From b16ecf8d4e3699f735fe57744831debb4994db6f Mon Sep 17 00:00:00 2001 From: Ewan Mellor Date: Wed, 27 Dec 2006 15:39:32 +0000 Subject: [PATCH] Added Brctl.get_state, to support upcoming PIF implementation. Signed-off-by: Ewan Mellor --- tools/python/xen/util/Brctl.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tools/python/xen/util/Brctl.py b/tools/python/xen/util/Brctl.py index 9ae8fdf51d..5dc9a7fb9f 100644 --- a/tools/python/xen/util/Brctl.py +++ b/tools/python/xen/util/Brctl.py @@ -28,6 +28,31 @@ def cmd(p, s): if not opts.dryrun: os.system(c) +bridgeRE = re.compile(r'([^\t]*)\t*[^\t]*\t*[^\t]*\t*([^\t]*)') +def get_state(): + fin = os.popen(CMD_BRCTL + ' show', 'r') + try: + bridges = {} + brlist = None + brname = None + first = True + for line in fin: + if first: + first = False + elif line[0] == '\t': + brlist.append(line.strip()) + else: + if brname: + bridges[brname] = brlist + m = bridgeRE.match(line) + brname = m.group(1) + brlist = [m.group(2).strip()] + if brname: + bridges[brname] = brlist + return bridges + finally: + fin.close() + def vif_bridge_add(params): """Add the network interface for vif on dom to a bridge. """ -- 2.30.2